import Cookies from "js-cookie";
// 存cookies 
// Cookie.set("存储的名字" ，存储的值 ,存储的天数)
export const SetCookie = (name , cookie)=>{
    Cookies.set(name , cookie ,{expires:7})
};
// 取缓存 Cookies.get(获取缓存的名字) 
export const GetCookie = name => Cookies.get(name);
// 删除缓存 Cookies.remove(需要删除的缓存名字)
export const RemoveCookie = name =>{
    Cookies.remove(name)
}
// 存缓存window.localStoage.setItem(存入的名字,存入的数据)
export const setStore = (name , obj)=>{
    window.localStorage.setItem(name , obj)
}

// 取缓存window.localStoage.getItem(要去的缓存的名字)
export const getStore =name =>window.localStorage.getItem(name)

// 删除指定缓存
// window.localStoage.removeItem(删除的缓存的名字)
export const removeStore = name =>{
    window.localStorage.removeItem(name);
}
// 清除用户电脑里面所有的本地缓存
export const getClear = ()=>{
    window.localStorage.clear()
}
// 存缓存window.sessionStorage.setItem() 
export const setSee = (name ,obj)=>{
    window.sessionStorage.setItem(name  , obj)
}
// 取缓存
export const getSee = name => window.sessionStorage.getItem(name)
// 删除缓存
export const removeSee = name => {
    window.sessionStorage.removeItem(name);
}

// setnullString 递归防null 
export const setnullString = (resp)=>{
    if(!resp){
        resp = {}
    }else{
        for(let i in resp){
            if(resp[i]&& typeof(resp[i])=="object"){
                setnullString(resp[i])
            }else{
                if(Object.is(resp[i] , null)){
                    resp[i]= {}
                }else if(Object.is(resp[i],'null')){
                    resp[i]=""
                }
            }
        }
        return resp
    }

}